package com.turboconnard.core;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

import com.turboconnard.data.Library;

public class MainActivity extends Activity {
	protected MainView _mainView;
	private GLSurfaceView mGLSurfaceView;
	protected Agd agd;
	private Library _library;
	
	public MainActivity() {

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d("ACTICITY : ", "ON CREATE");
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu pMenu) {
		
		super.onCreateOptionsMenu(pMenu);
		agd.menu.open(pMenu);
		return true;
	}

	/**
	 * Invoked when the user selects an item from the Menu.
	 * 
	 * @param item
	 *            the Menu entry which was selected
	 * @return true if the Menu item was legit (and we consumed it), false
	 *         otherwise
	 */
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Log.d("ACTICITY : ", "onOptionsItemSelected");
		return agd.menu.select(item);
	}

	public Agd go() {
		Log.d("ACTICITY : ", "go");
		// agd.menu = _menu;
		return null;
	};

	/**
	 * Invoked when the Activity loses user focus.
	 */
	@Override
	protected void onPause() {
		super.onPause();
	}

	/**
	 * Invoked when the Activity loses user focus.
	 */
	@Override
	protected void onStart() {

		super.onStart();
		Log.d("ACTICITY : ", "onStart");
		MainRenderer d = new MainRenderer(this);
		mGLSurfaceView = new MainView(this);
		mGLSurfaceView.setRenderer(d);
		setContentView(mGLSurfaceView);
		_library = new Library(this);

	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		// _mainThread.saveState(outState);
	}
}
